package com.task.common.util.body;

import java.util.HashMap;

/**
 * 通用Map
 * @author Huzz
 * @created 2021-11-30 10:50
 */
public class CommonModel extends HashMap<Object, Object> {

    public CommonModel() {

    }

    public CommonModel success() {
        return success(200, "成功");
    }

    public CommonModel success(String msg) {
        return success(200, msg);
    }

    public CommonModel success(Integer code, String msg) {
        this.put("statusCode", code);
        this.put("data", msg);
        return this;
    }

    public CommonModel fail() {
        return response(500, "失败");
    }

    public CommonModel fail(String msg) {
        return success(500, msg);
    }

    public CommonModel response(Integer code, String msg) {
        this.put("statusCode", code);
        this.put("data", msg);
        return this;
    }

    public CommonModel response(Integer code, Object data) {
        this.put("statusCode", code);
        this.put("data", data);
        return this;
    }

    @Override
    public CommonModel put(Object key, Object value) {
        super.put(key, value);
        return this;
    }

}
